<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class HuatiOwner extends Model
{

    public $timestamps = false;
    protected $table = 'tbl_huati_owner';

    ######关联关系 start#######
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'c_id');
    }

    public function huati()
    {
        return $this->belongsTo(Huati::class, 'huati_id', 'id');
    }

    ######关联关系  end########


    /**
     * 是否是圈主
     * @param $user_id
     * @return bool|mixed
     */
    static function IsOwner($user_id)
    {
        $huati_id = HuatiOwner::where('user_id', $user_id)->value('huati_id');
        return $huati_id ? $huati_id : false;
    }
}
